﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace RB2012.Models
{
    public class Contact
    {
        #region Explanation of Bind Exclude Not Being Used
        /*couldn't use Bind(Exclude="ID")
        //to keep validation from firing because method in controller
         * needed it to find the appropriate tutorial name lookup
         * so cancelled it out on the Controller side*/
        #endregion

        [Required(ErrorMessage = "You need to fill in a first name")]
        public string FirstName { get; set; }

        [Required(ErrorMessage = "You need to fill in a last name")]
        public string LastName { get; set; }

        [Required(ErrorMessage = "You need to fill in an email address")]
        public string Email { get; set; }

        public bool Tutorial { get; set; }

        [Required(ErrorMessage = "You need to fill in a comment")]
        public string Comment { get; set; }

        [Display(Name="Tutorial name")]
        public int TutorialID { get; set; }

        #region Conditional Binding Technique/Explanation
        /*useful validation technique for conditional binding.
        /in my case it wouldn't use due to the additional
         check on my drop down list (tutorial id, and tutorial name)
         * keeping it for now. to implement, add IValidatableObject to 
         * the class above (Contact View Model)
   
        //public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        //{
        //    if (Tutorial && (TutorialId==0))
        //        yield return new ValidationResult("Tutorial name must be supplied.");
        //}
         * */
        #endregion
    }
}